#pragma once
//1000000000 int  
namespace lht
{	
	template <size_t N>
	class BitSet
	{
public:
	BitSet()
	{
		_bits.resize(N / 8+1,0);
	}

	void set(size_t x)
	{
		size_t a = x / 8;
		size_t b = x % 8;
		_bits[a] |= (1 << b);
	}

	void reset(size_t x)
	{
		size_t a = x / 8;
		size_t b = x % 8;
		_bits[a] &= ~(1 << b);
	}

	bool test(size_t x)
	{
		size_t a = x / 8;
		size_t b = x % 8;
		return _bits[a] & (1 << b);
	}

	private:
		vector<char> _bits;
	};


	template <size_t N>
	class TwoBitSet
	{
	public:
		void set(size_t x)
		{
			bool inset1 = _bs1.test(x);
			bool inset2 = _bs2.test(x);
			if (inset1 == false && inset2 == false)
			{
				_bs2.set(x);
			}
			if (inset1 == false && inset2 == true)
			{
				_bs1.set(x);
				_bs2.reset(x);
			}
		}
		void print_once_num()
		{
			for (int i = 0; i < N; ++i)
			{
				if (_bs1.test(i) == false && _bs2.test(i) == true)
				{
					cout << i << endl;
				}
			}
		}

	private:
		BitSet<N> _bs1;
		BitSet<N> _bs2;
	};

void Test1()
{
	BitSet<100> bs;
	bs.set(8);
	bs.set(9);
	bs.set(20);
	cout << bs.test(8) << endl;
	cout << bs.test(9) << endl;
	cout << bs.test(20) << endl;
	bs.reset(8);
	bs.reset(9);
	cout << bs.test(8) << endl;
	cout << bs.test(9) << endl;
	cout << bs.test(20) << endl;
}

void Test2()
{
	int arr[] = { 3, 4, 5, 2, 3, 4, 4, 4, 4, 12, 77, 65, 44, 4, 44, 99, 33, 33, 33, 6, 5, 34, 12 };
	TwoBitSet<100> tbs;
	for (auto e : arr)
	{
		tbs.set(e);
	}
	tbs.print_once_num();
}

}